<h1>Leaves</h1>

<p><?= $this->Html->link('Request Leave', array('action'=>'request')) ?>
<?= $this->element('list', array(
    'entity' => 'Leave',
    'data'   => $leaves,
    'fields' => array(
        'Id'    => 'Leave.id',
        'User'  => 'User.email',
        'Type'  => 'LeaveType.name',
        'Start' => function($row) {
            return to_date($row['Leave']['start']);
        },
        'End' => function($row) {
            return to_date($row['Leave']['end']);
        },
        'Approved?' => function($row) {
            $app = $row['Leave']['approved'];
            if ($app === null) {
                return $this->App->approveControl($row['Leave']['id']);
            } else {
                return $app ? 'YES' : 'NO';
            }
        }
    ),
    'cantCreate' => true,
    'cantEdit'   => true
)) ?>